package com.sgb.kjwl.viewmodel.self.website;

import com.sgb.kjwl.AppConstant;
import com.sgb.kjwl.api.APIManager;
import com.swgk.core.view.entity.AliProofEntity;
import com.sgb.kjwl.repository.SelfRepertory;
import com.sgb.kjwl.view.ui.activity.self.websiteManage.WebsiteVideoActivity3;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MLog;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class WebsiteVideoModel3 extends BaseViewModel {

    private WebsiteVideoActivity3 activity;
    private SelfRepertory repertory;

    public WebsiteVideoModel3(WebsiteVideoActivity3 activity3, SelfRepertory tr){
        this.activity = activity3;
        this.repertory = tr;
    }

    //获取上传凭证
    public void getVideoParams() {
        DialogHelper.showProgressDialog(activity, null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        APIManager.getInstance().getSelfGoodsPublishAPI().getVideoParams().enqueue(new Callback<BaseEntity<AliProofEntity>>() {
            @Override
            public void onResponse(Call<BaseEntity<AliProofEntity>> call, Response<BaseEntity<AliProofEntity>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body().getState().equals("ok"))
                    activity.setAliInfo(response.body().getData());
            }

            @Override
            public void onFailure(Call<BaseEntity<AliProofEntity>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
                MLog.d(AppConstant.API_LOG, "error " + t.getMessage());
            }
        });
    }
}
